package com.demo.caizi.schedule;

import com.demo.caizi.biz.BizService;
import com.demo.caizi.biz.domain.CustomInfo;
import com.demo.caizi.config.context.CustomContext;
import com.demo.caizi.config.context.CustomContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import uk.co.jemos.podam.api.PodamFactory;

import java.util.concurrent.ThreadLocalRandom;

@Component
public class ScheduleSignJob {

    @Autowired
    BizService bizService;

    @Autowired
    PodamFactory podamFactory;

    @Scheduled(cron = "15 1 0/4 * * ? ")
    public void callRoll(){
        boolean loop = ThreadLocalRandom.current().nextBoolean();
        CustomInfo customInfo = podamFactory.manufacturePojo(CustomInfo.class);
        CustomContext context = new CustomContext();
        context.setCustomInfo(customInfo);
        CustomContextHolder.setHolder(context);
        if (loop) {

            bizService.newSign();
        }



    }
}
